#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
除法运算示例
"""

from mcp.client.stdio import stdio_client
import asyncio

async def main():
    # 连接MCP服务
    client = await stdio_client()
    
    # 调用除法运算
    result = await client.call_tool("divide", {"a": 15, "b": 3})
    print(f"15 ÷ 3 = {result}")
    
    # 浮点数除法
    result = await client.call_tool("divide", {"a": 10.5, "b": 2.5})
    print(f"10.5 ÷ 2.5 = {result}")
    
    # 测试除零异常
    try:
        await client.call_tool("divide", {"a": 5, "b": 0})
    except Exception as e:
        print(f"5 ÷ 0 错误: {str(e)}")

if __name__ == "__main__":
    asyncio.run(main())